package cn.edu.hqu.cst.crj.mediashowdemo3;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

public class play extends AppCompatActivity implements View.OnClickListener{
    String path;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);

        //返回
        findViewById(R.id.btn_back).setOnClickListener(this);

        requestAllPower();


        VideoView videoview = (VideoView)findViewById(R.id.videoView);

        videoview.setMediaController(new MediaController(this));
        Intent i = getIntent();


        //videoview.setVideoPath("/sdcard/DCIM/one.mp4");//(文件名根据实际情况修改)
        videoview.setVideoPath(i.getStringExtra("path"));//(文件名根据实际情况修改)
        videoview.start();


    }

    public void requestAllPower()
    {
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED)
        {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE))
            {
            } else
            {
                ActivityCompat.requestPermissions(this,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
            }
        }
    }

    public void onClick(View v) {
        Intent intent=new Intent();
        switch (v.getId()) {


            case R.id.btn_back:
                finish();
        }
    }
}
